package com.sjz.han.industry.adapters;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sjz.han.industry.R;
import com.sjz.han.industry.activites.ProductJsActivity;
import com.sjz.han.industry.activites.WaitJhMemberDetailActivity;
import com.sjz.han.industry.entities.WaitJhMemberEntity;
import com.sjz.han.industry.internetmanage.ReqestUrl;
import com.sjz.han.industry.utils.PicUtils;

import java.util.ArrayList;
import java.util.List;


/**
 *待激活成员适配器
 */
public class WaitJhMemberAdapter extends RecyclerView.Adapter<WaitJhMemberAdapter.ViewHolder> {
    private Context context;
    private List<WaitJhMemberEntity.WaitJhMemberData> datas = new ArrayList<>();
    public WaitJhMemberAdapter(Context context) {
        this.context=context;
    }

    @Override
    public int getItemCount() {
        return datas == null ? 0 : datas.size();
//        return 5;
    }
    public void setAdapterDatas(List<WaitJhMemberEntity.WaitJhMemberData> datas){
        this.datas=datas;
        notifyDataSetChanged();
    }
    @Override
    public WaitJhMemberAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new WaitJhMemberAdapter.ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_waitjhmember_item, parent, false));
    }

    @Override
    public void onBindViewHolder(WaitJhMemberAdapter.ViewHolder holder, final int position) {
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                context.startActivity(new Intent(context, WaitJhMemberDetailActivity.class).putExtra("userid",datas.get(position).userId));
            }
        });
        holder.djh_name_tv.setText(datas.get(position).username);
        holder.djh_phone_tv.setText("联系电话："+datas.get(position).phone);
        holder.djh_time_tv.setText("注册时间："+datas.get(position).excelCreateTime);
        PicUtils.showImageViewToCircle(context, R.mipmap.ic_wd_tx, ReqestUrl.BASE+datas.get(position).photo, holder.djhhy_photo_img);

    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        public ImageView djhhy_photo_img;
        public TextView djh_name_tv,djh_phone_tv,djh_time_tv;
        public ViewHolder(View itemView) {
            super(itemView);
            djh_name_tv=(TextView)itemView.findViewById(R.id.djh_name_tv);
            djh_phone_tv=(TextView)itemView.findViewById(R.id.djh_phone_tv);
            djh_time_tv=(TextView)itemView.findViewById(R.id.djh_time_tv);
            djhhy_photo_img=(ImageView)itemView.findViewById(R.id.djhhy_photo_img);
        }

    }
}